package cn.itrip.auth.service;

import cn.itrip.auth.exception.RedisException;
import cn.itrip.auth.exception.TokenProtectedException;
import cn.itrip.beans.pojo.ItripUser;
import cn.itrip.beans.vo.ItripTokenVO;

import java.text.ParseException;

public interface TokenService {

    //PC过期时间
    int TOKEN_TIMEOUT=5*60;
    int PROTECT_TIME=5*60;
    int DELAY_TIME=2*60;



    /**
     * 生成token
     * @param agent
     * @param itripUser
     * @return
     */
    public String genarateToken(String agent, ItripUser itripUser) throws Exception;




    public String genarateToken2(String msagent, ItripUser itripUser) throws Exception;

    /**
     *
     * @param tokenkey
     * @param itripUser
     * @return
     */
    public boolean saveToken(String tokenkey,ItripUser itripUser) throws Exception;


    /**
     * 校验token有效性
     * @param token
     * @param agent
     * @return
     */
    public boolean validateToken(String token,String agent);


    /**
     * 删除token
     * @param token
     * @throws Exception
     */
    public void deleteToken(String token) throws Exception;


    /**
     * 置换token
     * @param token
     * @param agent
     */
    public ItripTokenVO refreshToken(String token, String agent) throws TokenProtectedException, ParseException, RedisException;


}
